<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('数据集市列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>指标名称：</label>
                                <input type="text" name="na"/>
                            </li>
                            <li>
                                <label>所属系统：</label>
                                <select name="sdSys" th:with="type=${@baseSd.getItem('hos_sys')}">
                                    <option value=""></option>
                                    <option th:each="item : ${type}" th:text="${item.na}" th:value="${item.cd}"></option>
                                </select>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var prefix = ctx + "etl/check/config";
        function add() {
            $.modal.open("新建DM配置",prefix+"/add?type=1",900,600);
        };
        function submitHandler() {
            debugger;
            var rows = $('#bootstrap-table').bootstrapTable('getSelections');
            if(rows.length<1) {
                $.modal.alertError("至少需要选择一条数据");
                return ;
            }
            var data=[],tds;
            $.each(rows,function (index,item) {
                data.push({"idDrawDm":item.idDrawDm,"idIndex":item.idIndex,"tbDm":item.cdTb,"sdSys":item.sdSys});
            });
            $.ajax({
                url: prefix+"/addList",
                type: 'POST',
                dataType: 'json',
                data: JSON.stringify(data),
                contentType: 'application/json;charset=UTF-8',
                success: function (result) {
                    if(result.code=="0") {
                        $.modal.close();
                    }
                }
            });
        }
        $(function() {
            var options = {
                url: "/etl/dm/list",
                modalName: "数据集市",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'idDrawDm',
                    title: '',
                    visible: false
                },
                {
                    field: 'idIndex',
                    title: '指标'
                },
                {
                    field: 'naIndex',
                    title: '指标名'
                },
                {
                    field: 'cdTb',
                    title: '表名'
                },
                {
                    field: 'sdSys',
                    title: '所属系统'
                },
                {
                    field: 'des',
                    title: '备注'
                }]
            };
            $.table.init(options);
        });
    </script>
</body>
</html>